package com.h3c.nem.client;

import com.alibaba.fastjson.JSONObject;
import com.h3c.nem.bo.ElectronicSignBO;
import com.h3c.nem.bo.SendEmailBO;
import com.h3c.nem.config.MultiPartSupportConfiguration;
import com.h3c.nem.dto.beisen.PtEnumDTO;
import com.h3c.nem.vo.PtEsignRecordInfoVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author chenyifan
 * @date 2022/6/9 9:25
 */
@FeignClient(name = "ptability-manage", url = "${ability.url}", configuration = MultiPartSupportConfiguration.class)
//@FeignClient(name = "ptability-manage", url = "http://localhost:8099", configuration = MultiPartSupportConfiguration.class)
public interface AbilityClient {

    /**
     * 启动电子签章
     *
     * @param electronicSignBO
     * @param Authorization
     * @return
     */
    @PostMapping(value = "electronic/signPdfFile")
    String startElectronicSignature(@RequestBody ElectronicSignBO electronicSignBO, @RequestHeader("Authorization") String Authorization);

    /**
     * 进行公司签章
     * @param recordIds
     * @param Authorization
     * @return
     */
    @PostMapping(value = "electronic/checkAndSignOrg")
    String checkAndSignOrg(@RequestBody List<String> recordIds, @RequestHeader("Authorization") String Authorization);

    /**
     * 重新发起电子签章
     *
     * @param electronicSignBO
     * @param Authorization
     * @return
     */
    @PostMapping(value = "electronic/reSignFile")
    String reSignFile(@RequestBody ElectronicSignBO electronicSignBO, @RequestHeader("Authorization") String Authorization);

    @PostMapping(value = "ptEnum/queryEnum")
    JSONObject getPtEnum(@RequestBody PtEnumDTO ptEnumDTO, @RequestHeader("Authorization") String token);

    /**
     * 获取公共平台的token
     *
     * @param data
     * @return
     */
    @PostMapping(value = "comm/tokenTest", consumes = {"application/json"})
    String getPtabilityTokenByAccount(@RequestBody String data);

    /**
     * 发送邮件
     *
     * @param sendEmailBO
     * @return
     */
    @PostMapping(value = "email/sendEmailFile",consumes = {MediaType.APPLICATION_JSON_VALUE})
    Map<String, String> sendEmail(@RequestBody SendEmailBO sendEmailBO);

    /**
     * 查询分页
     * @param jsonObject 参数
     * @param token token
     * @return
     */
    @PostMapping(value = "electronic/getSignSfsIds", consumes = {"application/json"})
    JSONObject esignRecord(@RequestBody JSONObject jsonObject, @RequestHeader("Authorization") String token);

    /**
     * 下载sfs文件
     *
     * @param fileId
     * @param fileName
     * @param account
     * @return
     */
    @PostMapping(value = "ptUploadFile/downloadFile", headers = {"Authorization=${ptability.token}"})
    JSONObject downloadFile(@RequestParam("fileId") String fileId, @RequestParam("fileName") String fileName, @RequestParam("account") String account);


    /**
     * 上传文件
     *
     * @param uploadFile
     * @param busiType
     * @param busiId
     * @param appId
     * @return
     */
    @PostMapping(value = "ptUploadFile/uploadFile",
            consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
            headers = {"Authorization=${ptability.token}"})
    String uploadFileToSfs(@RequestParam("uploadFile") MultipartFile uploadFile,
                           @RequestParam(value = "clientIP", required = false) String clientIP,
                           @RequestParam(value = "busiType", required = false) Integer busiType,
                           @RequestParam(value = "busiId", required = false) String busiId,
                           @RequestParam(value = "appId") String appId,
                           @RequestParam(value = "operatorId") String operatorId,
                           @RequestParam(value = "operatorName") String operatorName);

    /**
     * 删除sfs文件
     *
     * @param fileId
     * @return
     */
    @GetMapping(value = "deleteSfsFile", headers = {"Authorization=${ptability.token}"})
    String deleteSfsFile(@RequestParam("fileId") String fileId);

    /**
     * 根据岗位编码获取岗位名称
     * @param postId
     * @return
     */
    @GetMapping(value = "bdPost/getPostNameByPostId")
    String getPostNameByPostId(@RequestParam String postId);



    @GetMapping(value = "ptEsignRecord/getRecentRecordInfo", headers = {"Authorization=${ptability.token}"})
    List<PtEsignRecordInfoVO> getTbOfferRecord(@RequestParam String workerId, @RequestParam Integer sceneType);

    @GetMapping(value = "ptDept/getDeptByDeptId", headers = {"Authorization=${ptability.token}"})
    JSONObject getPtDept(@RequestParam Integer deptId);
}
